package com.whmskj.xjlhsc.mobie.Scheduling.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.whmskj.xjlhbc.dto.JcQueryDto;
import com.whmskj.xjlhsc.mobie.Scheduling.Dto.RecordsOfEmployeeAwardsAndSancti;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @Author: Sakura
 * @Date: 2025/8/30 13:35
 * @Version: v1.0.0
 * @Description: TODO
 **/
@Mapper
public interface RecordsOfEmployeeAwardsAndSanctiMapper
        extends BaseMapper<RecordsOfEmployeeAwardsAndSancti> {

    @Select("SELECT ifnull(max(documentNumber+0),'202500000') documentNumber FROM recordsOfEmployeeAwardsAndSancti")
    RecordsOfEmployeeAwardsAndSancti selectMaxDocumentNumber();

    @Select("SELECT workshop, COUNT(*) as count, " +
            "SUM(CASE WHEN typeOfAward = '奖励' THEN f28c ELSE 0 END) as reward, " +
            "SUM(CASE WHEN typeOfAward = '处罚' THEN f28c ELSE 0 END) as punishment " +
            "FROM recordsOfEmployeeAwardsAndSancti " +
            "WHERE status = '已审核' " +
            "GROUP BY workshop")
    List<Map<String, Object>> selectWorkshopStatistics();

    List<RecordsOfEmployeeAwardsAndSancti> selectRecordsOfEmployeeAwardsAndSanctiList(JcQueryDto param);

}
